<template>
  <div :class="{ 'limitup-stock': true, 'not-last': notLast }" @click.stop="jump">
    <div class="stock-info">
      <div class="name">
        <span>{{ stockinfo.name }}</span>
        <atom-tag type="minor-fill" color="red" v-if="consecutiveNum" class="connecting-plate"
          >{{ consecutiveNum }}连板</atom-tag
        >
      </div>
      <div class="price-increase">
        <span class="now-price">{{ stockinfo.nowPrice | formatNumTwo }}</span>
        <span class="increase">{{ stockinfo.increase | format }}</span>
      </div>
    </div>
    <slot />
  </div>
</template>

<script>
import { jumpToFenShi, formatNumber } from '@/scripts/tools.js';
export default {
  props: {
    stockinfo: {
      type: Object,
      default: () => ({}),
    },
    consecutiveNum: {
      type: Number,
      default: 0,
    },
    notLast: {
      type: Boolean,
      default: true,
    },
  },
  methods: {
    jump() {
      jumpToFenShi(this.stockinfo.stockCode, this.stockinfo.market);
    },
  },
  filters: {
    format(num) {
      return formatNumber(+num, '+M.2%');
    },
    formatNumTwo(num) {
      return formatNumber(+num, 'M.2');
    },
  },
};
</script>
<style lang="less" scoped>
.limitup-stock {
  position: relative;
  box-sizing: border-box;
  &.not-last::after {
    position: absolute;
    content: '';
    box-sizing: border-box;
    // width: calc(100% - 48px);
    width: 100%;;
    left: 0;
    bottom: 0;
    // margin-left: 24px;
    border-bottom: 1px solid var(--text-8);
  }
  .stock-info {
    display: flex;
    align-items: center;
    .name {
      display: flex;
      align-items: center;
      font-family: PingFangSC-Regular;
      font-size: 32px;
      color: var(--text-1);
      letter-spacing: 0;
      line-height: 40px;
      font-weight: 400;
      .connecting-plate {
        margin-left: 12px;
      }
    }
    .price-increase {
      display: flex;
      justify-content: space-between;
      .now-price {
        font-family: THS;
        font-size: 32px;
        color: #ff2436;
        letter-spacing: 0;
        text-align: right;
        line-height: 40px;
        font-weight: 500;
      }
      .increase {
        margin-left: 80px;
        font-family: THS;
        font-size: 32px;
        color: #ff2436;
        letter-spacing: 0;
        text-align: right;
        line-height: 40px;
        font-weight: 500;
      }
    }
  }
}
</style>
